package liuds.music.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.widget.ListView;

import java.util.List;

import liuds.music.BaseFragment;
import liuds.music.model.Music;

/**
 * Created by Administrator on 2018/4/9.
 */

public class MainPagerAdapter extends FragmentPagerAdapter {

    private List<BaseFragment> list;
    private boolean showTitle = true;

    public MainPagerAdapter(FragmentManager fm, List<BaseFragment> list) {
        super(fm);
        this.list = list;
    }

    @Override
    public BaseFragment getItem(int position) {
        return list.get(position);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if (showTitle){
            return list.get(position).getTitle();
        }else{
            return super.getPageTitle(position);
        }
    }

    public void showTitle(boolean showTitle){
        this.showTitle = showTitle;
    }
}
